﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Web;
using System.Text;
using Zoo.Cat.WcfImageService.DataHelper;
using System.Configuration;

namespace Zoo.Cat.WcfImageService
{
    // 注意: 使用“重构”菜单上的“重命名”命令，可以同时更改代码、svc 和配置文件中的类名“Service1”。
    public class FileService : IFileService
    {

        public void UploadFile(Picture request)
        {
            using (SqlServerContext context = new SqlServerContext())
            {
                context.Set<Picture>().Add(request);
                context.SaveChanges();
            }
        }

        public Picture DownLoadFile(Guid id)
        {
            var item = new Picture();
            using (SqlServerContext context = new SqlServerContext())
            {
                item = context.Set<Picture>().Find(id);
            }
            return item;
        }

        public List<Picture> DownLoadFiles(List<Guid> listId)
        {
            var items = new List<Picture>();
            using (SqlServerContext context = new SqlServerContext())
            {
                items = context.Set<Picture>().Where(item => listId.Contains(item.Id)).ToList();
            }
            return items;
        }
    }
}
